Repository navigation
生产上线前加固:关闭 API 文档 + 移除测试登录旁路 + deploy-prod - #47
Merged
Merged
Conversation
added 4 commits
October 29, 2026 02:10
P-1: /docs, /redoc, /openapi.json and the GraphiQL page are now gated by Settings.expose_api_docs (env EXPOSE_API_DOCS, default false). POST /graphql keeps working either way. Adds tests/unit/test_expose_api_docs.py.
Deletes src/common/verification/test_bypass.py, the two consume() short-circuits, the Settings fields and the unit tests. Fixed-code test accounts no longer authenticate; every account must pass real SMS/email verification.
Adds a deploy_prod workflow_dispatch input and a deploy-prod job that needs [build-backend, deploy-test], so production always runs the exact digest the test environment just validated. Dependencies (redis/nacos) stay in /opt/thvote/prod/docker-compose.deps.yml, out of the compose file CI overwrites. Post-deploy smoke checks assert /docs is 404 (P-1) and the old bypass login no longer returns 200 (P-4).
CHANGELOG entry, readiness checklist P-1/P-4 ticked, bypass design doc archived as removed, captcha-onboarding section invalidated, scraper e2e instructions updated to require a real verification code.
TRUSTED_PROXY_IPS/ADMIN_ALLOWED_IPS are list[str], so pydantic-settings JSON-decoded them at the source layer and an empty string (the documented 'leave blank' form) raised SettingsError before any validator ran, crashing the process at import time. Switch both to NoDecode plus a tolerant parser accepting '', JSON arrays and comma-separated values.
added 2 commits
October 30, 2026 00:25
- src/common/crypto.py: AES-256-GCM + HKDF content/index keys + HMAC blind index - migration 0022: encrypted columns + (provider, subject_idx) unique index, plaintext nullable - user/user_identity: encrypted columns + *_plain accessors - DAO/service/admin: exact lookup by blind index, remove fuzzy identity search - import_legacy_voters.py: write ciphertext, dedup by subject_idx, --only-test-accounts - main.py: log PII DEK fingerprint at startup, fail fast if missing - docker-compose.prod.yml: mount pii_dek secret - scripts/verify_import.py: read-only import verification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
生产上线前加固 + 首次生产部署流水线。
改动
Settings.expose_api_docs(EXPOSE_API_DOCS,默认false);/docs、/redoc、/openapi.json与 GraphiQL IDE 一并关闭,POST /graphql不受影响。回归用例tests/unit/test_expose_api_docs.py。test_bypass.py、两个consume短路、两个配置字段与单测;测试/生产 Nacos 已删键。假号 + 固定码不再能登录。deploy_prod手动开关与deploy-prodjob(needs: [build-backend, deploy-test]),生产复用测试验证过的同一 digest;依赖(redis/nacos)由生产机docker-compose.deps.yml单独维护。验证
flake8 src/通过;pytest tests/除既有环境依赖型失败(integration 需真实 Postgres/Redis、test_whitelist_converter基线即失败)外全绿。prod_db连接与alembic 0021已核对。/docs404、旁路登录非 200(CI 脚本内置断言)。上线影响
main推送会自动重建并部署测试环境(现有行为),生产仍需手动 dispatch 勾选deploy_prod。main。